﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using Point2d.Geometry;

namespace Point2d.Graphics
{
    public class ViewControl
    {
        public bool _draging = false;
        public Point2 _cache = new Point2();
        public Vector2 _dragSize = new Vector2();
        GraphicsManager _graphicsManager = null;

        public ViewControl(GraphicsManager manager)
        {
            _graphicsManager = manager;
        }

        public void Start(Point from)
        {
            _cache._x = from.X;
            _cache._y = from.Y;

            _draging = true;
        }

        public void Draging(Point to)
        {
            if (_draging == false)
                return;

            _dragSize._width = to.X - _cache._x;
            _dragSize._height = to.Y - _cache._y;

            _cache._y = to.X;
            _cache._y = to.Y;

            _graphicsManager.Move(_dragSize);
        }

        public void End()
        {
            _draging = false;
        }
    }
}
